<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        用函数实现内置方法every 
    </div>
    <script>
        function myEvery( arr ,fn ) {
            for( var i = 0 ; i < arr.length ; i ++ ) {
                var res = fn( arr[i] , i , arr );
                if ( i == arr.length - 1 ) {
                    if ( res ){
                        return true ;
                    } else {
                        return false ;
                    }
                }
                if ( !res ) {
                    return false ; 
                }
            }
        }
        var arr = [ true , true ,  true , true , true , true , true , true ] ;
        var res = myEvery( arr , function ( item , key , arr ) {
            if ( item ) { 
                return true ;
            } else {
                return false ; 
            }
        }) ; 
        console.log(res);
    </script>
</body>
</html>